package inventory.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import inventory.entity.PermissionRecord;
import inventory.mappers.PermissionRecordMapper;
import inventory.service.PermissionRecordService;
import inventory.utils.UUIDUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author sxt
 * @since 2019-11-06
 */
@Service
public class PermissionRecordServiceImpl extends ServiceImpl<PermissionRecordMapper, PermissionRecord> implements PermissionRecordService {

    @Autowired
    PermissionRecordMapper permissionRecordMapper;

    @Override
    public void addUserPermissionRecord(String userId, List<Integer> permissionListIdList) {

        for (Integer item : permissionListIdList) {
            PermissionRecord permissionRecord = new PermissionRecord();
            permissionRecord.setUserId(userId);
            permissionRecord.setPermRecId(UUIDUtils.getId());
            permissionRecord.setPermissionListId(item);

            permissionRecordMapper.insert(permissionRecord);
        }
    }
}
